import os

def count_lines_in_file(file_path):
    try:
        with open(file_path, 'r') as file:
            lines = file.readlines()
            print(file_path,len(lines))
            return len(lines)
    except:
        return 0

def count_lines_in_directory(directory):
    total_lines = 0
    for root, dirs, files in os.walk(directory):
        for file in files:
            if file.endswith(".py"):
                file_path = os.path.join(root, file)
                # print(file_path)
                total_lines += count_lines_in_file(file_path)
    return total_lines

if __name__ == "__main__":
    project_directory = 'E:\\newsvn\\python\\water'  # 这里可以替换为实际的项目目录
    print(count_lines_in_directory(project_directory))